//
//  OperationTip.m
//  GKBHouse
//
//  Created by  on 12-8-9.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "OperationTip.h"

@implementation OperationTip
+ (NSString *)startOperat:(BOOL)OPEN name:(NSString *)name
{
    NSString *tipType = @"";
    if(OPEN)
    {
        tipType = NSLocalizedString(@"opening", nil);
    }
    else
    {
        tipType = NSLocalizedString(@"closing", nil);
    }
    // xxx，正在打开；xxx，正在关闭
    NSString *tip = [NSString stringWithFormat:@"%@,%@", name, tipType];
    
    return tip;
}
+ (NSString *)errorType:(ErrorType)type
{
    NSString *error = @"";
    if (type == ErrorTypeServerReturnFail) {//服务器返回失败
        error = NSLocalizedString(@"server return fail!", nil);
    }
    if (type == ErrorTypeNetworkFail) {//网络失败
        error = NSLocalizedString(@"network connect fail!", nil);
    }
    if (type == ErrorTypeServerDataFail) {//服务器数据有错误
        error = NSLocalizedString(@"server data fail!", nil);
    }
 
    return error;
}
+ (NSString*)operat:(NSString *)name open:(BOOL)open result:(BOOL)result errorType:(ErrorType)type
{
    //xxx,打开/关闭 成功！/失败！原因：0，1，2
    NSString *operat = @"";
    
    if (open) {
        operat = NSLocalizedString(@"open", nil);
    }
    else
    {
        operat = NSLocalizedString(@"close", nil);
    }
    NSString *operatResult = @"";
    if (result) {
        operatResult = NSLocalizedString(@"success", nil);
        
    }
    else
    {
        NSString *fail =  NSLocalizedString(@"failure!cause:", nil);
        NSString *typeStr = [OperationTip errorType:type];
        operatResult =  [fail stringByAppendingString:typeStr];
    }
    
    NSString *tip = [NSString stringWithFormat:@"%@,%@%@",name,operat, operatResult];
    
    return tip;
}
+ (NSString *)operatSuccess:(BOOL)success type:(ErrorType)type
{
    NSString *result = @"";
    if (success) {
        result =  NSLocalizedString(@"operat success!", nil);
    }
    else
    {
        NSString *fail =  NSLocalizedString(@"operat fail!cause:", nil);
        NSString *typeStr = [OperationTip errorType:type];
        result = [fail stringByAppendingString:typeStr];
    }
    
    return result;
}
@end
